package com.gitee.wsl.func.procedure.sample

import com.gitee.wsl.func.LongFunction
import com.gitee.wsl.func.procedure.Procedure

/**
 * Implementation of [Procedure] that holds on to the summation of elements seen so far,
 * determined by the [Function].
 */
class SumOfLongProcedure<T>(private val function: LongFunction<in T>) : Procedure<T> {
    var result: Long = 0
        private set

    override fun value(each: T) {
        this.result += this.function(each)
    }
}
